package com.walixiwa.m3u8downloader;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;

import com.walixiwa.m3udownloader.utils.DataConfig;
import com.walixiwa.m3udownloader.utils.DownloadManager;
import com.walixiwa.m3udownloader.utils.TaskShowManager;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        RecyclerView mRecyclerView = findViewById(R.id.recyclerView);
        TaskShowManager taskShowManager = new TaskShowManager().with(this).setRecyclerView(mRecyclerView);

        for (int i = 0; i < DataConfig.titles.size(); i++) {
            DownloadManager.addTask(DataConfig.titles.get(i), DataConfig.urls.get(i));
            taskShowManager.getAdapter().notifyItemInserted(DownloadManager.getTasks().size() - 1);
        }

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        DownloadManager.setListener(null);
    }
}
